$(document).ready(function() {
	var rpath = getRootPath();
	
	$('#class1').change(function() {
		var timestamp = (new Date()).valueOf(); 
		$.getJSON(rpath+ "/admin/business/getClassT/"+timestamp, {
			id : $('#class1').val()
		}, function(data) {
			$('#class2').empty();
			$('#class2').append($('<option></option>').text("所有分类").val(0));
			$('#class2').val(0);
			if(data['ret']==1)
				for(var tmp in data['class2List']){
					$('#class2').append($('<option></option>').text(data['class2List'][tmp]['name']).val(data['class2List'][tmp]['id']));
				}
		});
	});
	
	$('#region').change(function() {
		var timestamp = (new Date()).valueOf(); 
		$.getJSON(rpath+ "/admin/business/getAreaT/"+timestamp, {
			id : $('#region').val()
		}, function(data) {
			$('#area').empty();
			$('#area').append($('<option></option>').text("所有分类").val(0));
			$('#area').val(0);
			if(data['ret']==1)
				for(var tmp in data['areaList']){
					$('#area').append($('<option></option>').text(data['areaList'][tmp]['name']).val(data['areaList'][tmp]['id']));
				}
		});
	});
	
	$('#submitCheck').click(function(){  
		var class1=$('#class1').val();
		var class2=$('#class2').val();
		var region=$('#region').val();
		var area=$('#area').val();
		var groupName=$('#groupName').val();
		if($('#recycle').val()=='N') var recycle=0;
		else if ($('#recycle').val()=='T') var recycle=1;
		else if($('#recycle').val()=='F') var recycle=2;
		if($('#state').val()=='A') var state=0;
		else if ($('#state').val()=='N') var state=1;
		else if($('#state').val()=='U') var rstate=2;
		else if($('#state').val()=='P') var rstate=3;
		else if($('#state').val()=='S') var rstate=4;
		if($('#show').val()=='N') var show=0;
		else if ($('#show').val()=='T') var show=1;
		else if($('#show').val()=='F') var show=2;
		$('#businessListForm').attr('action', 'admin/business/businessList/' + class1 +
				'/'+class2+'/'+region+'/'+area+'/'+recycle+'/'+state+'/'+show+'/'+encodeURIComponent(groupName)
				);
	});  
});